<?php
/**
 * Created by JetBrains PhpStorm.
 * User: porterzhang
 * Date: 13-3-19 下午3:34
 * To change this template use File | Settings | File Templates.
 */
if (!defined('IN_MOBILE_API')) {
    exit('Access Denied');
}

include_once 'forum.php';
class cloud_api {
    function common() {
        global $_G;
        //判断是不是登录用户
        if (empty($_G['cloud_uid'])) {
            $variable = array(
                'code' => 1011,
                'messagestr' => lang('plugin/cloud', '1011'),
            );
            cloud_core::result(cloud_core::variable($variable));
        }
        //上传文件
        $_FILES['Filedata']['name'] = addslashes(diconv(urldecode($_FILES['Filedata']['name']), 'UTF-8'));
        $_FILES['Filedata']['type'] = $_GET['filetype'];
        //初始化上传的文件信息
        $file = plugin_cloud::update_init($_FILES['Filedata'], 'article');
        //保存到指定的文件夹中
        plugin_cloud::saveUpload($file);
        //将图片插入到数据库中，并返回id
        $insert = array(
            'caid' => 0,
            'name' => censor($file['name']),
            'display' => empty($_GET['display']) ? 1 : $_GET['display'],
            'url' => $file['attachment'],
            'lasttime' => TIMESTAMP,
        );
        $caaid = C::t('#cloud#cloud_article_attachment')->insert($insert);
        plugin_cloud::uploadMsg(0, $caaid);
    }

    function output() { }


}
?>

